package com.jiangyao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiangyao.common.utils.StringUtils;
import com.jiangyao.dao.IDemoDao;
import com.jiangyao.model.dto.DemoListPageDTO;
import com.jiangyao.model.entity.Demo;
import com.jiangyao.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * demo表熟悉框架 服务实现类
 * </p>
 *
 * @author yangyongchuan
 * @since 2020-06-05
 */
@Service
@Slf4j
public class DemoServiceImpl extends ServiceImpl<IDemoDao, Demo> implements DemoService {

	@Autowired
	private IDemoDao demoDao;

	@Override
	public Page<Demo> page(DemoListPageDTO listPageDTO) {
		QueryWrapper<Demo> demoQW = new QueryWrapper<>();
		if (StringUtils.isNotEmpty(listPageDTO.getUserName())) {
			demoQW.like("user_name", listPageDTO.getUserName());
		}
		Page<Demo> page = new Page<>(listPageDTO.getPageNo(), listPageDTO.getPageSize());
		this.page(page, demoQW);
		return page;
	}
}
